home *** CD-ROM | disk | FTP | other *** search
- ---PROC_LAB.DOC---
-
- The PROC Directive
-
- Syntax: name PROC NEAR
- name PROC FAR
- name PROC
-
- PROC is a directive provided for compatibility with Intel/IBM assemblers.
- I don't like PROC; and I recommend that you do not use it, even if you are
- programming for those assemblers.
-
- The idea behind PROC is to give the assembler a mechanism whereby it can
- decide for you what kind of RET instruction you should be providing. If you
- specify NEAR in your PROC directive, then the assembler will generate a
- near (same segment) return when it sees RET. If you specify FAR in your
- PROC directive, the assembler will generate a far RETF return (which will
- cause both IP and CS to be popped from the stack). If you simply leave
- well enough alone, and never code a PROC in your program, then RET will
- mean near-return throughout your program.
-
- The reason I don't like PROC is because it is yet another attempt by the
- assembler to do things "behind your back". This goes against the reason why
- you are programming in assembly language in the first place, which is to
- have complete control over the code generated by your source program. It
- leads to nothing but trouble and confusion.
-
- Another problem with PROC is its verbosity. It replaces a simple colon,
- given right after the label it defines. This creates a visual clutter in the
- program, that makes the program harder to read.
-
- Even if you are programming in that other assembler, and you need to code a
- far-return, I recommend that you create a RETF macro (it would have the single
- line DB 0CBH), and stay away from PROCs entirely.
-
-
- The ENDP Directive
-
- Syntax: [name] ENDP
-
- The only action A86 takes when it sees an ENDP directive is to return the
- assembler to its (sane) default state, in which RET is a near-return.
-
- NOTE that this means that A86 does not support nested PROCs, in which anything
- but the innermost PROC has the FAR attribute. I'm sorry if I am blunt, but
- anybody who would subject their program to that level of syntactic clutter
- has rocks in their head.
-
-
- The LABEL Directive
-
- Syntax: name LABEL NEAR
- name LABEL FAR
- name LABEL BYTE
- name LABEL WORD
-
- LABEL is another directive provided for compatibility with Intel/IBM assemblers.
- A86 provides less verbose ways of specifying all the above LABEL forms, except
- for LABEL FAR.
-
- LABEL defines "name" to have the type given, and a value equal to the current
- output pointer. Thus, LABEL NEAR is synonomous with a simple colon following
- the name; and LABEL BYTE and LABEL WORD are synonymous with DB and DW,
- respectively, with no operands.
-
- LABEL FAR does have a unique functionality, not found in other assemblers. It
- identifies "name" as a procedure that can be called from outside this program's
- code segment. Such procedures should have RETFs instead of RETs. Furthermore,
- I have provided the following feature, unique to A86: if you CALL the procedure
- from within your program, A86 will generate a PUSH CS instruction followed by a
- NEAR call to the procedure. Other assemblers will generate a FAR call, having
- the same functional effect; but the FAR call consumes more program space, and
- takes more time to execute.
-
- WARNING: you cannot use the above CALL feature as a forward-reference; the
- LABEL FAR definition must precede any CALLs to it. This is unavoidable, since
- the assembler must assume that a CALL to an undefined symbol takes 3 program
- bytes. All assemblers will issue an error in this situation.
-